<?php
	namespace app\index\controller;

	use \think\Db;

	class strategy extends Base{
		function show(){
			try{
				if($_POST){
					$page=(int)input('post.page');

					$length=8;

					$start=($page-1)*$length;

					$count=Db::name('strategy')->count('s_id');

					$list=Db::name('strategy')->limit($start,$length)->select();

					if($list){
						return $this->success(['list'=>$list,'page'=>$page,'count'=>$count,'length'=>$length]);
					}

					return $this->fail('数据为空');
				}
			}catch(\Exception $e){
				return $this->err($e);
			}
		}
		function row(){
			try{
				if($_POST){
					$id=(int)input('post.id');

					$row=Db::name('strategy')->where('s_id',$id)->find();

					if(!$row){
						return $this->fail('攻略信息不存在,即将返回...');
					}

					$row['s_createTime']=date('Y-m-d H:i',$row['s_createTime']);

					$row['s_text']=htmlspecialchars_decode($row['s_text']);

					return $this->success(['row'=>$row]);
				}
			}catch(\Exception $e){
				return $this->err($e);
			}
		}
		function sear_btn(){
			try{
				if($_POST){
					$sear=input('post.sear');

					if(!$sear){
						return $this->fail('请输入搜索关键字');
					}

					$list=Db::name('strategy')->where(['s_name'=>['like',"{$sear}"]])->select();

					if($list){
						return $this->success(['list'=>$list]);
					}

					return $this->fail('数据为空');
				}
			}catch(\Exception $e){
				return $this->err($e);
			}
		}
	}
?>